package com.example.testproj.remoteview;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.example.testproj.R;
import com.example.testproj.view.ViewTestActivity;

public class NotificationActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notification);
        startNotification();
    }

    private void startNotification() {
//        Notification notification=new Notification();
//        notification.icon=R.mipmap.ic_launcher;
//        notification.tickerText="hello World";
//        notification.when=System.currentTimeMillis();
//        notification.flags=Notification.FLAG_AUTO_CANCEL;
        Intent intent = new Intent(this, ViewTestActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

//
//        notification.contentIntent=pendingIntent;


        Notification.Builder builder = new Notification.Builder(this.getApplicationContext()).
                setSmallIcon(R.mipmap.ic_launcher).
                setContentText("hello world").
                setContentIntent(pendingIntent);

        Notification notification = builder.getNotification();

        NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        manager.notify(1, notification);
    }
}
